package com.mdxx.xczd.widget;

import com.mdxx.xczd.R;
import android.annotation.SuppressLint;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TextView;

public class LoginCustomView extends LinearLayout {

	private Context mContext;
	private ImageButton upBtn;
	private ImageButton downBtn;
	private TextView numText;
	private int num = 0;
	public LoginCustomView(Context context) {
		this(context, null);
	}

	public LoginCustomView(Context context, AttributeSet attrs) {
		this(context, attrs, 0);
	}

	@SuppressLint("NewApi") public LoginCustomView(Context context, AttributeSet attrs, int defStyleAttr) {
		super(context, attrs, defStyleAttr);
		mContext=context;
		LayoutInflater.from(mContext).inflate(R.layout.login_widget, this);
		initView();
	}

	private void initView(){
		upBtn = (ImageButton)findViewById(R.id.up);
		downBtn = (ImageButton)findViewById(R.id.down);
		numText = (TextView)findViewById(R.id.num);
		upBtn.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				if(num == 9) num =-1;
				num+=1;
				numText.setText(num+"");
			}
		});
		downBtn.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				if(num == 0) num =10;
				num-=1;
				numText.setText(num+"");
			}
		});
	}


	public String getNum(){
		return String.valueOf(num);
	}

}
